package com.eastcom.providor.service.entry;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.eastcom.bm.atom.DataAbnormal;

public  class DataAbnormalEntry {

	private List<String> colNs = new ArrayList<String>();

	private List<String> timS = new ArrayList<String>();

	// time[ col,value]
	private Map<String, Map<String, DataAbnormal>> values = new HashMap<String, Map<String, DataAbnormal>>();

	public void setValue(String time, String colName, DataAbnormal value) {
		//System.err.println(time+"    >>>>  "+colName +"   valie"+value);
		if (timS.contains(time)) {
			Map<String, DataAbnormal> val = values.get(time);
			if (!colNs.contains(colName))
				colNs.add(colName);
			DataAbnormal vD = val.get(colName);
			if (vD == null||vD.getIntegrityRatio()==null)
				val.put(colName, value);
			else if(value!=null&&value.getIntegrityRatio()!=null)
				val.put(colName, val.get(colName).getIntegrityRatio() > value.getIntegrityRatio() ? val.get(colName) : value);

		} else {
			timS.add(time);
			if (!colNs.contains(colName))
				colNs.add(colName);
			Map<String, DataAbnormal> val = new HashMap<String, DataAbnormal>();
			val.put(colName, value);
			values.put(time, val);
		}
	}

	public DataAbnormal getValue(String time, String colName) {
		Map<String, DataAbnormal> val = values.get(time);
		if (val != null)
			return val.get(colName);
		return null;

	}

}